const jwt = require('jsonwebtoken');
module.exports=(req,res,next)=>{
    //console.log(req.headers)
    try {
        const decoded=jwt.verify(req.headers.authorization,process.env.JWT_KEY);
        //req.session.userData=decoded;
        next();
    } catch (error) {
        res.status(401).json({
            message:'auth failed',
            error:error
        })
    }
    
}